package com.bjpowernode.boss.mvc.controller;

import cn.hutool.core.util.StrUtil;
import com.bjpowernode.boss.convert.UserPayInfoConvert;
import com.bjpowernode.boss.domain.UserPayInfo;
import com.bjpowernode.boss.enums.ajax.Code;
import com.bjpowernode.boss.mvc.model.result.AjaxResult;
import com.bjpowernode.boss.mvc.service.UserPayInfoService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商户支付信息 控制接口
 */
@RestController
@Slf4j
public class UserPayInfoController {

    @Resource
    private UserPayInfoService userPayInfoServer;

    @Resource
    private UserPayInfoConvert userPayInfoConvert;

    @GetMapping("/payInfo/loadData")
    public AjaxResult loadUserPayInfoData(@RequestParam String userNo) {
        log.info("要加载数据的商户id : {}" , userNo);
        if (StrUtil.isNotBlank(userNo)) {
            List<UserPayInfo> userPayInfoList = userPayInfoServer.loadUserPayInfoData(userNo);
            return AjaxResult.ok(userPayInfoConvert.toConvertUserPayInfoVoList(userPayInfoList));
        }
        return AjaxResult.fail(Code.REQUEST_PARAM_ERR);
    }
}
